<template>
  <div id="home-con" :style="'background:' + back">
    <div class="con">
      <div>
        <el-button type="success" @click="back = '#5FA916'"
          >颜色切换按钮</el-button
        >
      </div>
      <div><el-button @click="colocShow">显示颜色按钮</el-button></div>
    </div>
    <div class="zu">
      <div><Left @cutColor="cutColorLeft"></Left></div>
      <div><Right @cutColor="cutColorRight"></Right></div>
    </div>
  </div>
</template>

<script>
import Left from '@/components/Left'
import Right from '@/components/Right'
export default {
  name: 'home',
  data() {
    return {
      back: '#f5f5f5'
    }
  },
  methods: {
    colocShow() {
      alert(this.back)
    },
    // 子组件1 传值
    cutColorLeft(val) {
      this.back = val.back
    },
    // 子组件2 传值
    cutColorRight(val) {
      this.back = val.back
    }
  },

  components: {
    Left,
    Right
  }
}
</script>

<style lang="less" scoped>
#home-con {
  width: 100%;
  height: 100%;
  padding-top: 120px;
  box-sizing: border-box;
}
.con {
  width: 60%;
  height: 60px;
  margin: 0 auto;
  display: flex;
  > div {
    // width: 100px;
    margin: 0 auto;
  }
}
.zu {
  width: 60%;
  margin: 0 auto;
  height: 300px;
  display: flex;
  div {
    flex: 1;
  }
}
</style>
